package o;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appmarket.service.externalapi.view.ThirdApiActivity;
import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import com.huawei.hms.framework.network.restclient.dnkeeper.DNKeeperConfig;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant.KeyAndValue;

public class enm {
    public static boolean ˋ(String str) {
        if ("changeUser".equals(str) || "earnPoints".equals(str)) {
            return true;
        }
        return false;
    }

    public static void ˊ(final Context context, Handler handler, String str, String str2) {
        Logger.ˏ("BuoyJsHelper", "enter callHuaweiApp");
        if (str2 == null) {
            String str3 = "{\"openId\":\"9\",\"params\":[{\"name\":\"flag\",\"type\":\"String\",\"value\":\"gameBoxSDK\"},{\"name\":\"userId\",\"type\":\"String\",\"value\":\"$${USER_ID}\"}]}";
            CharSequence userId = UserSession.getInstance().getUserId();
            CharSequence charSequence = "$${USER_ID}";
            if (userId == null) {
                userId = "";
            }
            str2 = str3.replace(charSequence, userId);
        }
        if (handler != null) {
            handler.post(new Runnable() {
                public void run() {
                    try {
                        Intent intent = new Intent("com.huawei.appmarket.ext.public");
                        intent.setPackage(PackageUtils.HWGAMEBOX_PACKAGE_NAME);
                        intent.putExtra("thirdId", "4026620");
                        intent.putExtra("openStr", str2);
                        if (context instanceof Activity) {
                            context.startActivity(intent);
                        } else {
                            fab.ˎ().ˊ(null, ThirdApiActivity.class, intent, null, true);
                        }
                    } catch (Exception e) {
                        Logger.e("BuoyJsHelper", "call gamebox has exception.");
                    }
                }
            });
        }
    }

    public static void ˊ(final Context context, Handler handler, final String str) {
        dgh.ॱ(context, "15050106", KeyAndValue.NUMBER_01);
        if (handler != null) {
            handler.post(new Runnable() {
                public void run() {
                    enm.ˋ(str, context);
                }
            });
        }
    }

    private static void ˋ(String str, Context context) {
        if (context != null) {
            Intent intent = new Intent("android.intent.action.SEND");
            intent.setType(DNKeeperConfig.DNKEEPER_CONTENT_TYPE);
            intent.putExtra("android.intent.extra.SUBJECT", str);
            intent.putExtra("android.intent.extra.TEXT", str);
            intent.setFlags(268435456);
            context.startActivity(intent);
            return;
        }
        Logger.e("BuoyJsHelper", "context is null! share failed!");
    }
}
